package com.board.action.board;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.board.action.Action;
import com.board.dto.BoardRepDto;
import com.board.servlceimple.BoardRepServiceImp;
import com.board.servlet.helper.ActionForward;

public class WriteBoardAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		ActionForward forward=new ActionForward();
		BoardRepServiceImp service=BoardRepServiceImp.getInstance();
		
		String id=request.getParameter("id");
		String password=request.getParameter("password");
		String title=request.getParameter("title");
		String content=request.getParameter("content");
		BoardRepDto bdto=new BoardRepDto();
		bdto.setId(id);
		bdto.setPassword(password);
		bdto.setTitle(title);
		bdto.setContent(content);
		int count=service.writeBoard(bdto);
		request.setAttribute("count",count);
		
		forward.setUrl("writesuccess");
		
		return forward;
	}

}
